<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Enquete: ${titel}</title>
    </head>
    <body>
        <jsp:include page="include/header.jsp"/>
        <div id="content">
            <p id="error">
                ${error_enquete}
            </p>
            <form action="stop_enquete">
                <input type="hidden" value="${vragenCounter}" name="vragenCounter" />
                <input type="hidden" value="${vragenCounter}" name="vragenCounter" />
                <input type="submit" value="Stop de enquete" name="stop_enquete" />
            </form>
            <h2>${titel}</h2>
            <span id="vraagstelling">${result[0].vraagstelling}</span>
            <br />
            <form action="vraag">
                <c:choose>
                    <c:when test="${result[0].type == 'Open'}">
                        <c:if test="${sessionScope.antwoorden[fn:toLowerCase(vragenCounter - 1)] != ''}">
                            <c:set var="antwoord" value="${sessionScope.antwoorden[fn:toLowerCase(vragenCounter - 1)]}" scope="page" />
                        </c:if>
                        <input type="text" name="antwoord" value="${antwoord}"/>
                    </c:when>
                    <c:when test="${result[0].type == 'Meerkeuze'}">
                        <c:forEach items="${mc_antwoorden}" var="mc">
                            <c:choose>
                                <c:when test="${sessionScope.antwoorden[fn:toLowerCase(vragenCounter - 1)] == mc}">
                                    <c:set var="mc_checked" value="checked" scope="page" />
                                </c:when>
                                <c:otherwise>
                                    <c:set var="mc_checked" value="" scope="page" />
                                </c:otherwise>
                            </c:choose>
                            <input type="radio" name="antwoord" value="${mc}" ${mc_checked} />${mc}
                            <br />
                        </c:forEach>
                    </c:when>
                    <c:when test="${result[0].type == 'Waardering'}">
                        1
                        <c:forEach begin="1" end="5" step="1" varStatus="counter">
                            <c:choose>
                                <c:when test="${sessionScope.antwoorden[fn:toLowerCase(vragenCounter - 1)] == counter.current}">
                                    <c:set var="mc_checked" value="checked" scope="page" />
                                </c:when>
                                <c:otherwise>
                                    <c:set var="mc_checked" value="" scope="page" />
                                </c:otherwise>
                            </c:choose>
                            <input type="radio" name="antwoord" value="${counter.current}" ${mc_checked}/>
                        </c:forEach>
                        5
                    </c:when>
                </c:choose>
                <br />
                Voer hier eventuele toelichting in:
                <br />
                <c:if test="${sessionScope.extra[fn:toLowerCase(vragenCounter - 1)] != ''}">
                    <c:set var="toelichting" value="${sessionScope.extra[fn:toLowerCase(vragenCounter - 1)]}" scope="page" />
                </c:if>
                <textarea name="extra">${toelichting}</textarea>
                <br />
                <c:if test="${!eerstevraag}">
                    <input type="submit" value="Vorige vraag" name="nav_knop" />
                </c:if>
                <c:if test="${!laatstevraag}">
                    <input type="submit" value="Volgende vraag" name="nav_knop" />
                </c:if>
                <c:if test="${laatstevraag}">
                    <input type="submit" value="Verzend antwoorden" name="nav_knop" />
                </c:if>
            </form>
        </div>
    </body>
</html>